Method for refining a parameter of a contour in an image

ABSTRACT

Methods and apparatuses are disclosed for refining groupings of edge points that represent contours in an image. The methods and apparatuses decrease data dispersion and data quantization effects. The methods and apparatuses are particularly useful for accurate and robust detection of straight line-segment features contained in noisy, cluttered imagery occurring in industrial machine vision applications. Additionally, a measurement criterion of the quality of the detected line segments is introduced.

This application claims the benefit of U.S. Provisional Application No.60/131,932, filed Apr. 30, 1999.

FIELD

This invention relates to machine vision, and particularly to methodsand apparatuses for interpretation of edge point data from an image.

BACKGROUND

Dispersion of data is a common problem in many fields, including imageprocessing. In image processing, data fails to converge to one groupingfor numerous reasons, such as, imperfections in the imaging environment,the algorithm(s) employed, and/or the discrete nature of processing thedata using a computer. Data dispersion detrimentally affects some typesof image processing more than others. For instance, finding lines inimages is more detrimentally effected by dispersion than findingregions. Typically, the integrity of smaller groupings of data, such aslines, relative to the remainder of the image, suffer more fromdispersion effects. It is also difficult to identify elements composedof a relatively small amount of data because of confusing appropriatedata with superfluous data.

An example of dispersion of edge points of a line is illustrated usingFIG. 1, not drawn to scale, which depicts an imaged line 102 havingmultiple edge-point directions 100, shown schematically. An edge pointis derived from underlying image pixels, where an image pixel is apicture element characterized by a grey value, where an image can berepresented as an array of image pixels. A plurality of connected edgepoints creates a contour, such as a line or boundary 200 between tworegions 202 and 204, illustrated in FIG. 2. The direction of an edgepoint 210 is perpendicular to the line 200 upon which the edge point 208resides. Turning back to FIG. 1, the edge points 110 of the line 102 donot share a common direction 100, but are distributed about a peakangle, as shown in the discrete-angle histogram 104. The edge-pointdirections 100 fall into multiple discrete bins 108 that are distributedaround a peak bin 106, where the peak bin 106 represents the mode of thehistogram (i.e. the primary direction of the edge points 110 in the line102). The lack of convergence of all the edge points 110 to the peak bin106 illustrates the typical data dispersion present for lines in images.Lines detected using the Hough line-transform method also suffer fromthis problem.

The majority of line finding algorithms in machine-vision applications,are variations of the Hough line-transform method, described in U.S.Pat. No. 3,069,654. The Hough line-transform method transformscharacteristics of edge points into line characteristics, and representsthe line characteristics on a Hough space, where a point in the Houghspace represents a line.

The characteristics of the edge points include the edge-point position,denoted (x, y), edge-point direction, denoted θ, and optionally,edge-point magnitude, denoted M, which are all measured in Cartesianspace. The edge-point position is typically a function of the positionof a neighborhood of the underlying image pixels. The edge-pointmagnitude and direction are a function of the change in grey value ofthe image pixels that contribute to the edge point.

The characteristics of an edge point, (θ, x, y, and optionally M) aretransformed into line characteristics (d, c, and α) Typically, thecharacteristics of edge points in a contour are called features (such asposition), while characteristics derived from the features are calledparameters (such as line angle).

The line characteristics are illustrated in Cartesian space in FIG. 3.The line characteristics include a line angle 302, denoted α, which isthe angle of the line 300 from the horizontal, a distance-vector 304,denoted d, which is the shortest distance from the origin of acoordinate system 314 to the line 300, and, optionally, a collineardistance 306, denoted c, which is the distance from the edge point 308to the place where d touches the line 300, in Cartesian space, d issigned to differentiate between lines with identical α and d parameterson opposite sides of the origin 314. More specifically, the sign of d isnegative if the angle 312 of d from the horizontal in Cartesiancoordinates is less than 180° and greater than, or equal to, zeros(i.e., 180°>β≧0); and positive when the angle 312 of d is less than360°, and greater than, or equal to, 180° (i.e., 360°>⊖≧180°).

d, c, and α are generated from the following Hough-transform equations:

 d =x·sin(θ)−y·cos(θ)  [1]

c =x·cos(θ)+y·sin(θ)  [2]

α_(degrees)=[θ+90]_(mod180)  [3]

d and α are stored on a Hough space.

FIG. 4A depicts an instance of a Hough space 400 for lines. The Houghspace for lines is a two-dimensional space in which lines from an imageare recorded. The Hough space is adequately represented as atwo-dimensional array of bins 402. One axis 404 represents theline-angle, α, and the other axis 406 represents the distance vectors,d. A point on a Hough space represents a line.

During the transformation, for each edge point in an input image: thevalues of d and α are calculated, and the bin of the Hough space, whoserange includes the value of d and α for each edge point, is incremented.Once all the edge points in the input image have been examined, theHough space is searched for maximum values, using peak detection, amethod known in the art. The bin having the highest value in the Houghspace represents the strongest line detected in the input image, thesecond highest local maxima represents the second strongest linedetected, and so forth.

Each bin 402 in the Hough space represents a discrete range of anglesand a discrete range of distance vectors. FIG. 5 shows an instance of aquantization of the angles for a Hough space, where 360° is divided into64 bins. Each of the 64 bins has a range of 5.62 degrees per bin, wherethe first bin accommodates the angles within 0-5.62°, the second binaccommodates the angles within 5.62°-11.24°, and so on.

Typically, the line-angle range and/or distance-vector range for eachbin in the Hough space, and the divisions of ranges between the bins,are driven by system and application parameters, and often do notexactly represent the line angles or distance vectors in a given image.Thus, the partitioning of the line angle and the distance vector intodiscrete bins hinders detecting lines whose edge points straddle theboundaries, such as lines with a line angle of 5.62°, in the aboveexample. The edge points of such lines, typically, transform into morethan one bin, thus, it is more difficult to detect these lines, as isfurther discussed in J. Brian Burns, Allen R. Hanson, and Edward M.Riseman, “Extracting Straight Lines”, IEEE Transactions on PatternAnalysis and Machine Intelligence, 8(4), 1986.

The effects of dispersion and the number of partitions in an axis aredecreased by increasing the range of data accepted in each bin. However,increasing the range decreases precision of the line angles and/ordistance vectors. As illustrated using FIG. 6, which depicts a 59° line600 and a 51° line 610 and their respective discrete-angle histograms602 and 612 derived from a Hough space. A Hough space created using afour-bit representation for angle partitions the line-angle axis of theHough space so that the edge points 604 and 614 of both lines 600 and610 all map to bin two in the Hough space. Thus, the ability is lost todistinguish between a 51° line and 59° line in Hough space.

Other techniques known in the art, such as a Point Spread Functionupdate method, for example, also decrease dispersion effects. For eachedge point, the Point Spread Function update method increments more thanone bin with a partial weighting. Although the edge points do notcontribute 100% to the weight of the appropriate bin, it is less likelyany edge points fail completely to contribute to the weight of theappropriate bin. Although the Point Spread Function update methodcompensates, in part, for dispersion, it also causes a loss of precisionbecause the Point Spread Function tends to smear the Hough space peaks.

An additional problem with image processing smaller contours is theinability to identify appropriate groupings of edge points of eachcontour given the superfluous noise and background clutter. The paper W.Eric L. Grimson and Daniel P. Huttenlocher “On the Sensitivity of theHough Transform for Object Recognition,” Transactions on PatternAnalysis and Machine Intelligence, 12(3), 1990, discusses how linefinding and object detection using Hough transforms suffers fromsuperfluous noise and background clutter, particularly when trying todetect shorter lines.

Also, the Hough transform is only as precise as the underlyingedge-point data, which is limited according to current technology.Further, the precision cannot be greatly increased by interpolating theedge-point data to a higher number of bits because, eventually, theinterpolated bits do not represent meaningful precision.

SUMMARY

The invention provides methods and apparatuses for refining a parameterof a contour in an image. The contour is represented on a firstparameter space and a second parameter space, where the first parameterspace and the second parameter space are defined by a plurality ofparameter axes, each of the parameter axes represents a contour 5parameter and has bins adapted to receive edge points. The firstparameter space and the second parameter space are offset from oneanother along one of the plurality of parameter axes. To represent thecontour on the first parameter space and the second parameter space,first, a plurality of contour parameters are calculated for each edgepoint of an image. Next, bins of the first parameter space and thesecond parameter space are filled with the same edge points (i.e. data)according to the plurality of contour parameters. Then, the firstparameter space and the second parameter space are merged to create thehybrid space, where each of the edge points is represented once in thehybrid space. Thus, the hybrid space allows refinement of the parameterrepresented on the first dimension because of the offset and themerging.

For instance, in a preferred embodiment, the parameter refined is theline angle of a line contour represented on a Hough space. First, thedirection of the edge points, which is an example of an edge-pointfeature, is used in a Hough line transformation to calculate the lineangle, which is an example of a contour parameter. The line angle isrepresented as discrete bins on one axis of a first Hough parameterspace and one axis of a second Hough parameter space that are offsetfrom one another along the line-angle axis by one-half of a bin. Eachedge point is represented in one bin of the first Hough parameter spaceand one bin of the second Hough parameter space. One of the bins (eitheron the first Hough parameter space or the second Hough parameter space)for each edge point is a better representation of the contour parameter,for that edge point and/or for the contour of which the edge point is amember. Accordingly, those bins (i.e., a sub-set of bins from the firstHough space and a sub-set of the bins from the second Hough space) arechosen to be merged to form one hybrid space having each of the edgepoints represented therein substantially only once. Thus, the line-angleparameter of the contour is refined because the edge points that yieldtwo adjacent line angle parameter values in one of the Hough spacesconverge to a single line angle parameter value in the other Houghspace, and the bin to which the edge points converge is selected to beincluded in the hybrid space.

Among other advantages the invention recovers edge points that areotherwise split across parameter space bins due to quantization effectsby providing two offset mapping schemes for parameters generated foreach edge point, and then using in a single hybrid space the moreappropriate mapping for each bin.

The invention overcomes various problems with the prior art, including,but not limited to, minimizing the effect of, and decreasing the extentof, dispersion of edge points; de-emphasizing the effect of quantizingranges of features of edge points or quantizing ranges of parametersderived from features of edge points; and finding a line that straddleboundaries between the edge-point quantizations in a Hough space.

BRIEF DESCRIPTION OF THE DRAWINGS

The invention will be more fully understood from the following detaileddescription, in conjunction with the accompanying Figs., wherein:

FIG. 1 depicts a contour, edge-points of the contour, and edge-pointdirections. Also shown is a histogram of the edge-point directions;

FIG. 2 is a graphical representation of an edge and the direction of anedge point;

FIG. 3 illustrates a line-parameterization format that includes adistance vector, line angle for a line, and a collinear distance of oneof the edge points of the line;

FIG. 4A is a graphical diagram of a traditional Hough space for lines,which uses the line format depicted in FIG. 3;

FIG. 4B is a graphical diagram of an annotated Hough space, which usesthe line format depicted in FIG. 3. Also shown is a bin thereon, and anedge-point array;

FIG. 5 depicts an instance of a partitioning scheme of acontinuous-angle range into discrete, quantized values;

FIG. 6 depicts instances of two contours, edge-points of the contour,edge-point directions, and their respective angle histograms;

FIG. 7 is a schematic diagram of a machine-vision system for practice ofthe invention;

FIG. 8 is a flowchart summarizing operation of a preferred embodiment ofa method according to the invention that refines a, contour representedon a parameter space;

FIG. 9 is a flowchart detailing operation of annexing for one embodimentof the method of FIG. 8;

FIG. 10 is a diagram illustrating the recovery of edge points using theannexing of FIG. 9;

FIG. 11 and FIG. 11A are diagrams illustrating two possible groupings ofthe same edge points;

FIG. 12 is a diagram illustrating a plurality of lines, including anidealized line, a line exhibiting an accumulated-line-fit error, a linewith edge-point-polarization errors, a line having a small edge-pointdensity, a line having both an accumulated-line-fit error andedge-point-polarization error, and a line having an accumulated-line-fiterror, edge-point-polarization error, and small edge-point density,respectively; and

FIG. 13 is a flowchart detailing operation of an embodiment of a methodaccording to the invention that creates a hybrid-parameter space.

DETAILED DESCRIPTION

The methods and apparatuses disclosed herein refine groupings of edgepoints that represent contours in an image. The method is particularlyuseful for refining straight-line segments identified using a Houghtransformation, where the straight-line segments are from productionimages typically available in the semiconductor and electronicsindustries. Though this is the form of a preferred embodiment, thisembodiment should be considered illustrative, and not restrictive.

FIG. 7 illustrates a machine system 710 of the type in which theinvention is practiced. The system 710 includes a capturing device 716,such as a conventional video camera or scanner that generates an imageof an object 712. Image data (or pixels) generated by the capturingdevice 716 represent, in the conventional manner, the image intensity(e.g. color or brightness) of each point in the scene at the resolutionof the capturing device 716.

The capturing device 716 transmits the digital image data via acommunications path 718 to an image analysis system 720. This can be aconventional digital data processor, or a vision processing system ofthe type commercially available, for example, from the assignee hereof,Cognex Corporation, programmed in accord with the teachings hereof torefine groupings of edge points from an image.

The image analysis system 720 may have one or more central processingunits 722, main memory 724, an input-output system 726, and one or moredisk drives (or other mass storage device) 728, all of the conventionaltype.

The system 720 and, more particularly, central processing unit 722, isconfigured by programming instructions according to the teaching hereofto refine groupings of edge points from an image, as described infurther detail below. Those skilled in the art will appreciate that, inaddition to implementation on a programmable digital data processor, themethods and apparatuses taught herein can be implemented in specialpurpose hardware.

FIG. 8 illustrates a flowchart detailing a preferred embodiment of themethod of the invention, where steps of the method are denoted in thedetailed description in parentheses. One instance of a preferredembodiment is refining contours that are represented on a parameterspace.

First, an input image is acquired (800), and, optionally, pre-processed(802), as known in the art. The pre-processing is application specific,and can include known techniques, such as smoothing and sub-sampling,for example.

Next, the edge data is generated (804) using edge detection, a techniqueknown in the art, such as Sobel edge detection, for example. The edgedata generated includes, edge-point position, edge-point direction, andedge-point magnitude. In a preferred embodiment, the edge-point positionis generated to sub-pixel precision by the method described in commonlyassigned U.S. Pat. No. 5,657,403 or other tools known in the art.

Although edge data is generated for many positions in the image, theedge data is significant only for edge points having stronger edge-pointmagnitudes. Insignificant edge points due to frame grabber noise, otherimaging environment issues, or random fluctuations in pixel values,typically, increase processing time without adding precision, and oftenmake it difficult to evaluate the edge data in the image. Optionally,these insignificant edge points are removed. In addition, edge-pointmagnitude values usually increase gradually in a “smear” as theyapproach an edge and then decrease as the edge is crossed. Optionally,some of the edge points that are near, but not at, an edge are alsoremoved.

Preferably, the edge points are removed using peak detection (806), atechnique known in the art, which thins out the edge points before theedge points are used to generate the parameter space (808). Optimally,the peak detector removes the edge points that are not peak points,thereby, leaving a single point-wide contour. As known in the art, peakpoints, typically, are stronger than an ambient level and have a valuethat is greater than, or equal to, the neighboring points of atwo-point, four-point, or eight-point neighborhood, as further describedin Cognex 3000/4000/5000, Programmable Vision Engines, Image Processing,Chapter 4 Edge Detection Tool, pages 215-216, (1996) incorporated hereinby reference.

Next, a parameter space is formatted to store the edge-point data. Theparameter space used depends on the contour being refined and theparameterization chosen for the contour, where the contour can be aline, a circle, an arc, or a generic boundary, for example. Preferably,the contour is one that can be defined by a mathematical description.Further, as known in the art, the same contour can be represented bymultiple parameterizations. It should also be apparent that one or moreparameters can be represented for each contour on the parameter space.

In a preferred embodiment, the contour refined is a line, parameterizedby d 304 and α 302, illustrated on FIG. 3, and represented on a Houghspace. The size of the Hough space along the angle axis is computedusing principles known in the art, and as further described in Cognex3000/4000/5000, Programmable Vision Engines, Vision Tools, Chapter 3Line Finder, pages 166-175,(1996) incorporated herein by reference. FIG.4B depicts an instance of an annotated Hough space. The size of theHough space along the distance-vector axis 402, denoted L_(space), is afunction of the maximum edge-point position and the resolution chosen bythe user, which can be computed using the following equation:$\begin{matrix}{L_{space} = {\left\lceil \frac{\sqrt{l^{2} + h^{2}}}{g} \right\rceil + 1}} & \lbrack 4\rbrack\end{matrix}$

Where g is the range of d for each bin, also called herein thegranularity, (typically set from 0.5 to 2.0), and l, h, are the widthand height, respectively of the input image. Other techniques can alsobe used to compute the Hough-space dimensions without departing from thescope of the invention.

In a preferred embodiment, the parameter space does not just contain theweight of the edge points in each of the bins; the parameter space isannotated to also contain references to edge-point data. In theannotated Hough space example of FIG. 4B, each Hough bin 408 willcontain a weight field 410 and an edge-point list 412, which containsthe addresses of the edge points contributing to the bin. The edge-pointlist 412 is represented mathematically as a one-dimensional array,denoted EPL_(d,α)(EP₀ . . . EP_(n)), containing the addresses of eachedge-point array 414, such as address EPL(EP₀). The sum of all edgepoints in the edge-point lists 412 of all the bins 408 must equal thenumber of edge points input into the Hough transform, denoted here as N.

An edge-point array 414, associated with each address of the edge-pointlist 412, contains edge-point data 416, generated earlier during theedge-detection step (804) and, optionally, the peak detection step (806)of FIG. 8, and data generated from the Hough processing 418. Theedge-point data 416 includes (X, Y), M and/or θ, where which edge-pointdata is required will depend upon how the edge-points are annexed andother optional steps, as hereinafter described. The Hough-processingdata includes the Hough bin address (“HBA”) 420 to which the edge pointbelongs, and optionally d, α, and c.

In a preferred embodiment, the edge-point list 412 is generated and theHBAs 420 initialized using a two pass technique. The first passincrements the weight 410, W, of each bin 408 pursuant to the Houghtransform algorithm previously described, and also initializes the Houghbin address 420, HBA, for each edge-point array 414, EP_(n). The secondpass sets the length of each edge-point list, n, as the value of theweight 410, W, of each of the bins 408; and fills the edge-point list412, EPL, by adding the address of each edge-point array 414 to theedge-point list 412, EPL, after examining the HBA 420 associated witheach edge-point array 414. As necessary, for each embodiment, the otherHough-transform data, being d, α, and c is added to the edge-point array414, during the first pass, when the HBA is initialized. Thus, eachedge-point array 414 is assigned a Hough bin 408, equal to the HBA, andeach non-zero weighted Hough bin 408 will contain an address list of theedge points contributing to the respective Hough bin, that is theEPL_(d,α).

Returning to FIG. 8, next, the weight of the bins of the parameter spaceis searched, in at least one dimension, for local maxima, using peakdetection previously described (810). If the groupings are representedas a multi-dimensional array, peak detection is employed in one or moredimensions. Preferably, when one-dimensional peak detection is employedon a multi-dimensional array, the dimension chosen for peak detection isthe dimension that exhibits more dispersion of the data oralternatively, it is the dimension for which an embodiment of thehybrid-space of FIG. 13 cannot partially compensate.

The local maxima found are termed seed-peaks, and the seed peaks areranked according to their weight (811). Other ranking schemes that aretailored to an application can be used without departing from the scopeof the invention.

The seed peaks are primary peaks, and, therefore, more likely torepresent the proper parameterization of the contour (e.g. d and α oflines from the image in the Hough space example). Considerations, suchas processing time, can lead to denoting only a sub-set of the localmaxima as seed peaks, without departing from the scope of the invention.

In one embodiment, the seed peaks are ranked according to a spatialdistribution of the edge points of the peak in addition to weight of thepeak. For lines, the spatial distribution is measured as the variance ofthe collinear distances of the edge points of the peak. A preferredembodiment ranks lines having more spatially distributed edge pointshigher than more dense lines, when both lines have substantially thesame weight. The invention recognizes that a subsequent line fit, asdescribed hereinafter, is more accurate on edge points distributed overa greater spatial range. Using the teachings herein, those skilled inthe art should recognize that the spatial distribution of lines could beused alone, or in conjunction with, other parameters, such as weight, todetermine the quality of a line.

Further, using the teachings herein, those skilled in the art shouldrecognize that the spatial distribution of other contours or groupingscould be used to bias the designation of a grouping as a primarygrouping.

Next, one or more of the edge points are annexed, from one or more bins,to one or more seed peaks (812), thereby, refining the groupings of edgepoints in one or more bins, as is further described with reference toFIG. 9.

FIG. 9 details the annexation operation of one embodiment of the methodof FIG. 8, where steps of the operation are shown in the detaileddescription in parentheses. The ranking of the seed peaks is input (900)into the annexation operation.

Preferably, each seed peak is examined sequentially according to theposition assigned during ranking (902). Consequently, the edge points ofa seed peak can be annexed to a higher ranking seed peak before the seedpeak is examined. Other heuristics can be used without departing fromthe scope of the invention.

Using one embodiment of the Hough space example, an edge point isannexed to a seed peak (908) by re-calculating the distance vector ofthe edge point (906), using a new edge-point direction, denotedθ_(intermediate), derived from a least-squares-fit line to the edgepoints of the seed-peaks (904) in the distance-vector calculation of aHough transformation, instead of using the edge-point direction, θ,which was previously determined during edge detection (804). Thisexample is described using the diagram of FIG. 10, which illustrates therecovery of edge points, not drawn to scale, with continuing referenceto FIG. 9.

FIG. 10 illustrates fourteen edge points and corresponding edge-pointdirections hypothetically generated using the Hough transform equationshereinbefore described. Six edge points, denoted with a circle, share acommon edge-point direction and are the edge points of the seed peak inthis example, denoted the seed population 1000. Two sets of four otheredge points denoted by triangular edge points 1006 and square edgepoints 1008, respectively, represent two other adjacent bins of edgepoints along the distance-vector axis, denoted a triangle bin and asquare bin, respectively.

The new edge-point direction, denoted θ_(intermediate), is generated byfirst fitting a least-squares line 1002 to the positions of the seedpopulation 1000 (904). The angle 1004 α_(intermediate) of theleast-squares line 1002 is converted into an edge-point directionθ_(intermediate), using the following equation:

θ_(intermediate(degrees))=α_(intermediate)−90°  [5]

Next, in a preferred embodiment, a parameter of the edge points of atleast one adjacent bin is recomputed. In this example, the triangle binalong the distance-vector axis is accessed, and the distance vector ofthe triangular edge points 1006 is re-calculated using θ_(intermediate)and the underlying triangular edge-point positions in thedistance-vector calculation, represented mathematically as follows:

d _(refined) =x·sin(θ_(intermediate))−y·cos(θ_(intermediate))  [6]

Next, if d_(refined) of any of the triangular edge points 1006 arewithin the range of d for the seed population 1000, then the triangularedge points 1006 are annexed to the seed population 1000 (908).

After all the edge points in the triangular bin are examined, atermination condition is examined (910), which determines whetheranother bin will be examined. Numerous termination conditions can beused without departing from the scope of the invention, such as acondition which balances processing time over precision, for instance.In a preferred embodiment, the termination condition is that a new binis not accessed after either finding an empty bin (i.e. a bin having anull weight) or no edge points are annexed from a non-empty bin alongboth directions of the parameter axis (e.g. both directions of thedistance-vector axis).

In this example, after the triangular edge points 1006 are annexed tothe seed population 1000, the termination condition is not met (910) sothe square bin is accessed (906), d_(refined) is computed for each ofthe square edge points 1008 (906), and the square edge points 1008 areannexed to the seed population 1000 (908). When all the square edgepoints 1008 have been examined, the seed population 1000 is refined(i.e. augmented) from a weight of six to a weight of fourteen, includingsix circular edge points 1000, plus four triangular edge points 1006,and four square edge points 1008.

Once annexing for one seed population is complete (e.g. the terminationcondition (910) is met), the next seed peak is selected (902), for whichthe steps (904)-(910) are repeated until no more seed peaks remain to beselected (912).

Other fitting techniques can be used to fit a contour without departingfrom the scope of the invention, such as an ellipse fit, for example.

Instead of calculating θ_(intermediate), d_(intermediate) could becalculated using the edge points of the seed-peaks, by averaging, forexample. Thereafter α_(refined) is calculated instead of d_(refined) forthe edge points of the other bins, and compared with the seed-peak rangefor α_(refined).

Additionally, c_(refined) can be calculated and used alone, or inconjunction with, the d_(refined) or α_(refined) to determine if theedge point should be annexed to the seed population.

Further, it should be apparent that the distance vector does not need tobe recalculated for all the edge points in each bin, and othervariations, depending upon the image and application, can be used, suchas, only recalculating d for every third edge point in each bin.

Similarly, not every bin needs to be accessed. Accessing just theneighboring bins or every third bin, for example, may be sufficient forcertain applications. In applications other than Hough, the accessedbins are chosen according to their relative position along a boundary ortheir relative position as stored in a histogram, for example.

Turning to FIG. 11, with continuing reference to FIG. 8, FIG. 11illustrates an instance of four refined seed populations of edge points1100, 1102, 1104, and 1106 (i.e. lines) that were generated by the peakannexation (812).

Next, optionally, a second fitting algorithm is performed for eachrefined seed. population to which edge points were annexed (814). Forexample, four line fits are performed to the edge-points 1114 of each ofthe seed populations 1100, 1102, 1104, and 1106, respectively. Abisector (not shown) of each pair of parallel lines 1118 represents theline generated from the least-squares line fit to each of the refinedseed populations 1100, 1102, 1104, and 1106.

Some applications may require reporting closely spaced contours, such aslines 1100, 1102, 1104, and 1106 as one or two contours, depending uponthe objectives of the application (816). For example, in a wirebonderapplication, one line segment should be reported for each side of alead. A more abstract definition of a line than that employed heretoforeis used to merge the lines 1100, 1102, 1104, and 1106 or other contours.The merging is accomplished using well documented techniques, such astechniques of data clustering analysis, see Anil K. Jain and Richard C.Dubes, “Algorithms for Clustering Data” Chapter 3, pp. 89-101, PrenticeHall, Englewood Cliffs N.J. 1988 incorporated herein by reference.

In one embodiment, lines are grouped (816) by merging all lines havingdistance-vector values and angle values within a user-supplied toleranceof the distance value and angle value of the refined seed peak with thehighest population. Which in this example, is a user-supplied delta fromthe distance vector and line angle values of the line 1100. The mergingresults in two groups 1108 and 1110, shown in FIG. 11A, instead of four1100, 1102, 1104, and 1106.

It should be apparent, that other higher level grouping criteria can beused without departing from the scope of the invention.

If the contours were optionally merged (816), another iteration of thefitting algorithm is performed on the merged segment (818). A bisector(not shown) of each pair of parallel lines 1118 represents a linegenerated from a least-squares line fit to each of the merged lines 1108and 1110.

Next, the lines are optionally scored (820) and passed to anotheralgorithm or reported to a user (822).

In a preferred embodiment, the quality of a line is based upon acomposite score of three independent intrinsic properties: edge-pointdensity, accumulated-line-fit error, and edge-point polarization.

FIG. 12 illustrates the three properties. Line 1200 represents anidealized line that has no accumulated-line-fit error (i.e., eachedge-point position coincides substantially exactly with the line fitthrough it); has unit edge-point density (i.e., the edge-points aresubstantially equally spaced); and has an ideal edge-point polarization(i.e., all the edge-point directions are substantially identical andorthogonal to the line angle.) Line 1202 has an accumulated-line-fiterror, where one definition of the error is the orthogonal distance fromeach edge point to the line summed for all the edge-points of the line.Line 1204 has an edge-point-polarization error, where the error ischaracterized as the standard deviation of the edge-point directionsplus the difference between the mean of the edge-point directions andthe expected direction (i.e., the line angle−90°). Other definitions ofedge-point polarization error can be used without departing from thescope of the invention, such as using only standard deviation, forexample. Line 1206 has unequally spaced edge points, and thus, has anedge-point density less than one. Line 1208 has bothaccumulated-line-fit and edge-point-polarization errors. Line 1210 has acombination of all three errors.

Edge-point density and accumulated-line-fit error are documented in theart as measures of line quality, see, Bertold K. P. Horn, Robot Vision,pp. 47-55. MIT Press, Cambridge Mass. 1993, incorporated herein byreference.

The invention recognizes that edge-point polarization provides furtherinformation about the quality of a line, and is useful alone, or inconjunction with, edge-point density, accumulated-line-fit error, orother line characteristics. Edge-point polarization of a line, and theuse of it as a measure of quality of a line, is a recognition of theinvention.

An alternate embodiment further refines the extraction of contours byemploying a hybrid-parameter space, which is described with reference toFIG. 13. Two parameters spaces are created (1300-1302) and (1304-1306),space A and space B, respectively, each having bin divisions offset fromthe other by one-half of a bin; and then merged into one hybrid-space(1310) so that each of the edge points is represented once in thehybrid-space. For example, at an angle quantization of five bits (32states), which yields a resolution of 11.25 degrees/bin, an initialHough bin using Map A covers the range from 0 to 11.25°, while in theinitial Hough bin in Map B covers the range 354.37 to 5.650. The edgepoints are represented once on the A space and once on the B space.

The invention recognizes that initially, lines that straddle theboundaries in one mapping are centered within a bin in the secondmapping, thus, the edge points will cluster more in an alternatemapping.

Next, the edge points are merged (1310) into one hybrid-space such thateach of the edge points is represented once in the hybrid-space. Whichmapping, map A or map B, of the edge point is retained in thehybrid-space is determined using a voting procedure, and the resultanthybrid-space is a hybrid space that is composed of bins from bothmappings.

In one embodiment, the voting procedure to choose the bins for thehybrid-space is implemented using a two-pass technique adapted from thevoting procedure described in J. Brian Burns, Allen R. Hanson, andEdward M. Riseman, “Extracting Straight Lines”, IEEE Transactions onPattern Analysis and Machine Intelligence, 8(4), 1986, incorporatedherein by reference. In the first pass, each edge point votes for thebin of space A or space B that possesses the greater weight. At the endof the first pass, each bin in both spaces has a support count. In passtwo, the bins for which more than 50% of their constituent edge pointshave supported them are propagated forward into the hybrid-space. Othervoting procedures can be used without departing from the scope of theinvention, such as biasing one space over the other, for example.

Additionally, the quantization of parameters from any parameter space,such as the distance-vector, for example, can be addressed by processingthe parameters as described with reference to FIG. 13, without departingfrom the scope of the invention.

Further, it should be apparent to one skilled in the art that more thantwo parameter spaces can be merged to create the hybrid-space withoutdeparting from the scope of the invention, where the spaces are offsetby a fraction of a bin.

It should also be apparent that the fractional offset can divide the binequally, such as ½ and ½, or unequally, such as ¾ and ¼, and will dependupon the application.

It should be apparent to one skilled in the art that the edge points canbe grouped by other Hough transforms, such as Hough circles or Houghellipses, for example.

Further, the edge points of a line can be grouped using other Houghparameterizations, such as a slope-intercept parameterization of a line,for example.

It should also be apparent that the invention can refine one or moreparameters stored on a one-dimensional space or multi-dimensional space,respectively such as the parameterization of a Hough ellipse.

It should also be apparent that the group examined for annexing can bethe adjacent group or other group directed by an application specificheuristic, which ends as directed by the termination condition, aspreviously described.

Preferably, the group characteristic is re-calculated using some aspectof the seed population, such as described with reference to FIG. 9, forexample. The exact nature of the recalculation is application specific,and can be, for example, using a second boundary extracting method torefine edge data.

It should be apparent that the method can refine many different coarsergroupings of edge points. However, the method easily lends itself torefining groupings of edge points in an image that are related to eachother by at least one mathematical definition, such as by an equation orapproximation.

Those skilled in the art will appreciate that some, or all, of the stepsof preprocessing the image, detecting edge points, detecting peaks,annexing edge points, merging lines, scoring lines, and fitting linesdescribed hereinbefore can be combined and effected as hardwareimplementations, software implementations or a combination thereof.

Furthermore, while many operations are described herein utilizing animage from a industry application, it should be appreciated that any ofthe images described herein can be subject to further processing, suchas by filtering using a gaussian filter, median filter, smoothingfilter, morphological filter or the like known in the art, in order toimprove image quality.

Those skilled in the art will also realize that using reduced-resolutionimages to generate the edge points, for example, could decreaseprocessing time. Further, the method can use any combination offull-resolution and reduced-resolution images. However, use ofreduced-resolution images typically results in a loss of accuracy.

Those skilled in the art will realize that processing time can also bedecreased by performing any of the computations described herein usingsampled data, such as generating best-fit equations from sampled data,for example. Sampled data is a subset of the available data points, suchas every third data point, for instance.

Other modifications and implementations will occur to those skilled inthe art without departing from the spirit and the scope of the inventionas claimed. Accordingly, the above description is not intended to limitthe invention except as indicated in the following claims.

I claim:
 1. A method for refining at least one contour parameter of a contour in an image, the method comprising: detecting edge points in the image; calculating a plurality of contour parameters for each of the edge points; filling a first parameter space with the plurality of contour parameters of the edge points, the first parameter space defined by a plurality of parameter axes having first bins, where each of the plurality of parameter axes represents one of the plurality of contour parameters, and where each non-null bin of the first parameter space represents a contour; filling a second parameter space with the plurality of contour parameters of edge points, the second parameter space defined by a plurality of parameter axes having second bins, where each of the plurality of parameter axes represents one of the plurality of contour parameters, and where each non-null bin of the second parameter space represents a contour, the second parameter space being fractionally offset from the first parameter space along at least one of the plurality of parameter axes; and merging the second parameter space and the first parameter space to create a hybrid-parameter space such that each of the edge points is substantially represented once in the hybrid-parameter space.
 2. The method of claim 1, wherein the contour is a line, the first parameter space and the second parameter space are Hough-line spaces, and the plurality of parameter axes include a distance-vector axis and a line-angle axis.
 3. The method of claim 2, wherein the offset is along the line-angle axis.
 4. The method of claim 1, wherein the edge points have features and wherein calculating the plurality of contour parameters of the edge points further includes: calculating the plurality of contour parameters of the edge points using the features.
 5. The method of claim 1, wherein each of the first bins and the second bins has a weight equal to a number of the edge points in each of the first bins and the second bins, respectively, and wherein the merging further includes: comparing the weight of the first bins of the first parameter space to the weight of the second bins of the second parameter space for each of the respective edge points to determine a greater-weight bin for each of the respective edge points; determining hybrid bins in both the first parameter space and the second parameter space having more than half of the edge points of each of the first bins and second bins being the greater-weight bin; and creating the hybrid-parameter space composed of the hybrid bins.
 6. The method of claim 1, wherein the hybrid-parameter space includes some of the first bins from the first parameter space and some of the second bins from the second parameter space.
 7. The method of claim 1, wherein the merging further includes: merging a subset of the second bins from the second parameter space and a subset of the first bins from the first parameter space to create the hybrid-parameter space such that each of the edge points is substantially represented once in the hybrid-parameter space.
 8. The method of claim 1, further comprising: filtering the edge points by peak detection before filling the first parameter space and the filling second parameter space.
 9. An apparatus for refining a contour parameter of a contour from an image, the apparatus comprising: an image having edge points, calculation means adapted to calculate a plurality of contour parameters for each of the edge points; a first parameter space, defined by a plurality of parameter axes, where each of the plurality of parameter axes represents one of the plurality of contour parameters, each of the parameter axes having first bins, the first bins being adapted to receive the edge points by the plurality of contour parameters, where each non-null first bin of the parameter space represents a contour; a second parameter space, defined by a plurality of parameter axes, where each of the plurality of parameter axes represents one of the plurality of contour parameters, each of the parameter axes having second bins, the second bins being adapted to receive the edge points by the plurality of contour parameters, where each non-null second bin of the second parameter space represents a contour, the second parameter space being fractionally offset from the first parameter space along one of the plurality of parameter axes; filling means, in communication with the calculation means, adapted to fill the first parameter space and the second parameter space according to the plurality of contour parameters of the edge points; a hybrid-parameter space adapted to receive a sub-set of the first bins and a sub-set of the second bins; and merging means, adapted to merge the second parameter space and the first parameter space to create the hybrid-parameter space such that each of the edge points is substantially represented once in the hybrid-parameter space.
 10. The apparatus of claim 9, wherein the contour is a line, the parameter spaces are Hough-line spaces, and the plurality of parameter axes are a distance-vector axis and a line-angle axis.
 11. The apparatus of claim 10, wherein the offset is along the line-angle axis.
 12. The apparatus of claim 9, wherein the edge points have features and wherein the calculation means is adapted to calculated the plurality of contour parameters of the edge points using the features.
 13. The apparatus of claim 9, wherein the hybrid space includes a subset of the second bins from the second parameter space and a subset of the first bins from the first parameter space.
 14. A method for refining at least one contour parameter of a contour comprised of edge points, the edge points having features, the method comprising: calculating a plurality of contour parameters for each of the edge points using at least a portion of the features; generating a first parameter space defined by a plurality of first parameter axes, where each of the plurality of first parameter axes represents one of the plurality of contour parameters, each of the plurality of first parameter axis divided into a first set of discrete bins, the bins adapted to receive edge points according to the plurality of contour parameters of each of the edge points; generating a second parameter space defined by a plurality of second parameter axes, where each of the plurality of second parameter axes represents one of the plurality of contour parameters, each of the plurality of second parameter axis divided into a second set of discrete bins; the bins adapted to receive edge points according to the plurality of contour parameters of each of the edge points, the second parameter space being fractionally offset from the first parameter space along at least one of the plurality of parameter axes; assigning the edge points to one of the bins in each of the first parameter space and the second parameter space according to the plurality of contour parameters of each of the edge points, where each non-null bin of the first parameter space and the second parameter space represents a contour; and merging the second parameter space and the first parameter space to create one hybrid-parameter space such that each of the edge points is substantially represented once in the hybrid-parameter space, thereby refining the at least one contour parameter of a contour.
 15. The method of claim 14, wherein the contour is a line, the parameter spaces are Hough-line spaces, and the plurality of parameter axes are a distance-vector axis and a line-angle axis.
 16. The method of claim 15, wherein the offset is along the line-angle axis.
 17. The method of claim 14, wherein the hybrid-parameter space includes some of the bins from both the first parameter space and the second parameter space.
 18. The method of claim 14, further comprising: filtering the edge points by peak detection before assigning the edge points to the first parameter space and the second parameter space.
 19. The method of claim 14, wherein the merging further includes: merging a subset of the second bins from the second parameter space and a subset of the first bins from the first parameter space to create the hybrid-parameter space such that each of the edge points is substantially represented once in the hybrid-parameter space. 